package com.youi.third.shareclound;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.sec.sdk.SecClient;
import com.sec.sdk.bean.BaseResponse;
import com.sec.sdk.bean.RemitBatchRequestDTO;
import com.sec.sdk.bean.RemitDetailRequestDTO;
import com.sec.sdk.constants.SecGatewayConstants;
import com.sec.sdk.exception.SecGatewayException;

public class SharecloundUtil {

	//商户应用ID
    private static final String APPID = "101912191611";
    //商户编号
    private static final String MERCHANTNO="101912191611";
    //商户密钥
    private static final String MERPRIVATE="MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCOOCyZDtdRin3hD1F6JDiV0d4SnxQXPazWejZbQMumgHhbynf4CkgeizLm9EGXrJk3wzI/Ly8i75n+7nbDBWfKoasnSb8/2Bq6p+QuOj/oQ9fibXh9cpF87168aT9/SSxbJxpJK2Is9Gc+iXcxTB3dHy6AqnYBg9GHE3YxRfKTrobNUyu815+26tI6oRcLtUH6sy3ZTOZasCLb8C3wJmWoGKw+sOV/yedEc22SQdn549P/pVhzfGbY0DtUqaP7VVKY4oiW4CC693cpj8hGvKidsBf4ATgNS0H6956hSLFguPReaqklHL+2LRqbK+qyEu7SzDxi06u4aJh2HBwC8XM3AgMBAAECggEAU68kNu/vrPBj/6FG3SshDK9QD/8BEGffItkI0QtAifnAWKq7iv1p0GcyDYoeaoRKJ/C4yUsXXmREZiilQz4UA7y7fEO9wHCF0d1mu/jUj/QTvQ2TP6XBjBVB1nXLwjcpXX2VzwYzH6a0daznsN9MF0f40gb7pwqMqQG/o2C4S0MfMPl026uUUWb6VSdoCumuJ7DVpLLaCSuF5oxJEKkJPhN2NgeOnfQ21yv4KsT/+PcKDQ2nZ70h9isBYTa1Pq7n6wpILTZkr+AW1rVeppl7/4WXtqGCmXEkqHfhxfAfWVMpj6ZOB3Hzd3C3aD2iPVs1a3QmoTOxUudn+0EJslQLYQKBgQDEqrK1ikmXTneCos3vWvseNFu/2JfHbjRFubBmi7RNuqo6Xnf0xlLgWDqukSYI6M9Rp3REhNg3jrycM5cVMQxO3wKp3xkJ4tebO/8+Xci7c9W6Ion+/JpNLeCnWxqMD/pnAlP0Lo6Ba0lAHnJsIgly6iYFJoqbf9au8J4ya1Zi5wKBgQC5IE5AdUTKXWU4Gu/Ky72vKtJdmichxzYvjojwBTB5AFb9OJomacVh6fdBU4LXUFMtJvS803QC3obXmfILylFBbK5K1e0JFmbOd2sFsQC1Sz9PUGHpbiLkVxtfTOmRet5pOklSIznlMd5OAPnsoq58MJmdiEENyY5rzdTRNpezMQKBgDCMOsVZt8TkF9hlvBRkDy1rm2KGYyFV8Q1tQ0BtKDsv4ym5fD8uXfMHlKTXK95zKgpsHeV0LbO5RpIAokEW9ITbxFqOui2Yk8S8UMvidtTfSVlDgXEyhhybQKPPd4QvxY58IqFahM8p3tE3MuPCmzaE2pHW68xrCGHy//pOSOrtAoGBAIgQHnNxvWWez041PhknNfsQ1hzFuA0zhbfeYvdGWSIWBdmHSIUDKHeWpov0/S2TdA6zmx1NrO6O7zx3gVb5FE+puVB3ewg61sTZMGe2eHbHH3kD83LF6A87lnqs5N5wGBfvJwSfr2WtCV77iLVLvEK61azbADVJ9st1NP2vyj+BAoGAYJ0C4+ZilssphC9nLUwgqwRyymbdr5d0Q2UT1k4HCp4tAdcI+ZrHh6M25ziCjLnJt3LBdGB+qeVCtbUc4iORS8b+EQu/RT01+nfqaxsWZoab1FAjsvylRxz29hiMu7C4CCL4Cxv/f7AYEP90CMJ2wnR0KuVfU0J0oxcQKBB7rs0=";
    //回调地址
    private static final String NotifyUrl="";
    
   /**
    * 云享代付工具 
    * @param custBatchNo
    * @param batchAmt
    * @param batchNum
    * @return
    * @throws SecGatewayException
    * @throws IOException
    */
   public static String shareCloundPay(String custBatchNo,String batchAmt,Integer batchNum) throws SecGatewayException, IOException {
	   SecClient secClient = new SecClient(SecGatewayConstants.SERVER_URL,"settle.remit.api.payment", APPID,MERPRIVATE,"001","2013-01-01 08:08:08",20000,20000);
       //业务参数构建
       RemitBatchRequestDTO remitBatchRequestDTO = new RemitBatchRequestDTO();
       //商户批次号
       remitBatchRequestDTO.setCustBatchNo(custBatchNo);
       remitBatchRequestDTO.setBatchNum(batchNum);
       //new BigDecimal 时请写string类型 防止精度丢失
       remitBatchRequestDTO.setBatchAmt(new BigDecimal(batchAmt));
       remitBatchRequestDTO.setServerCallbackUrl(NotifyUrl);
       List<RemitDetailRequestDTO> list = new ArrayList<RemitDetailRequestDTO>();
       for (int i = 0; i < batchNum; i++) {
    	   RemitDetailRequestDTO detail=new RemitDetailRequestDTO();
    	   //商户打款明细订单号
    	   detail.setCustOrderNo("");
    	   //付款金额保留两位小数
    	   detail.setOrderAmt(new BigDecimal(""));
    	   //收款银行卡户名
    	   detail.setRecvCustName("");
    	   //收款人证件类型
    	   detail.setRecvIdType("IDENTITY");
    	   //收款人证件编号
    	   detail.setRecvCardNo("");
    	   //收款银行名称
    	   detail.setRecvBankName("");
    	   //付款备注
    	   detail.setRemark("");
    	   list.add(detail);
       }      
       remitBatchRequestDTO.setRemitDetailList(list);
       BaseResponse responseDTO = secClient.excute(remitBatchRequestDTO);
       return responseDTO.getResponse();
   }
    
}
